	Mandelbrot Microscope  Ver. 2.10
	Copyright 1986 by Radix 2 Software of Loomis, CA

	Written by Jeff Parsons


	This file, MBROT.COM, and related files can be freely copied
	and distributed, provided that all original copyright notices
	are left intact.


	Preface

	This is information on the Mandelbrot Microscope (MBROT) program.
	It may take a small amount of mathematical background to
	appreciate, but provided one has an IBM PC with a color/graphics
	adapter (and preferably color monitor), an infinite variety of
	complex images can be generated, with a high degree of
	magnification.  And although this program is not unique (the
	program "Mandelzoom" was described in the August 1985 issue of
	Scientific American), it does have several features that can
	make the time-consuming task of computing a graph more tolerable.

	
	Several features of note are that MBROT can compute the often
	lengthy computations as a background task while you use your
	PC for more mundane tasks such as accounting or wordprocessing.
	In addition MBROT can create individual frames of a continuous
	'movie' such that you can create a zooming effect as you choose
	each frame in continuously increasing resolution.

	To see this later effect, type MBROT at the system prompt and
	restore from file 'mem', at the questions as follows:

		A:\>mbrot

		Mandelbrot Microscope  Version 2.10
		Copyright by Radix 2 Software  May 1986

		Suggested values in ( ), default values in [ ]

		Restore from file (Y/[N])? Y
		Enter file #: MEM

		Press any key to continue...


	What follows is a magical zoom into the etheric reaches of the
	mathematical world of the the Mandlebrot set.


	Table of contents

		  I. Description of the Mandelbrot set
		 II. Using the Mandelbrot Microscope program
Š		III. Information on the sample graphs
		 IV. Advanced features
		  V. Technical information


	I. Description of the Mandelbrot set

	This program's primary accomplishment is to compute and graph,
	on the complex number plane, any selected region within or
	surrounding the Mandelbrot set.  To very briefly describe
	the Mandelbrot set, it is the set of all complex numbers that,
	when fed into an iterative algorithm, produce results that are
	finite, even after a large number of iterations.  The algorithm is
	designed to stop once it is known whether the "ultimate" result
	will be infinitely large (as is the case with most points in the
	complex plane), or will never exceed some finite value (which makes
	it a bona fide point of the Mandelbrot set).

	The heart of that iterative algorithm uses a recursive function to
	generate a sequence of complex numbers (a recursive function is one
	that uses results of its previous terms to help compute subsequent
	terms).  As in most recursive functions, the first term, f(0), must
	be pre-defined, and in this case it is 0 + 0i.  Like all complex num-
	bers, the first 0 represents the "real" part of the complex number,
	whereas the second 0 represents the "imaginary" part.  Also, graphing
	complex numbers on the complex number plane is similar to graphing
	(x,y) points on the familiar x-y plane, since "real" parts are mapped
	along the horizontal (x) axis, and "imaginary" parts are mapped along
	the vertical (y) axis.

	The expression that generates all the terms beyond f(0) (that is,
	f(1), f(2), etc.) can be written as

		f(n) = f(n-1)^2 + (a + bi)

	where (a + bi) represents the complex number to be evaluated, and
	like f(0), has a real part (a) and an imaginary part (b).  To further
	illustrate the algorithm, start with an actual complex number, such
	as -0.75 + 0.1i.  Since f(0) is already defined as 0 + 0i, and since
	squaring that value doesn't change it,

		f(1) = (0 + 0i)^2 + (-0.75 + 0.1i)
		     = (-0.75 + 0.1i)

	The algorithm requires that once we have computed a term, we compute
	its "size", and if the size is 2.0 or greater, then it can be assumed
	that the values will continue growing larger -- on into infinity.
	That would then "disqualify" the point from membership in the Mandel-
	brot set, and so would not be graphed as such.  The "size" of a
	complex number (a + bi) is the square root of a^2 + b^2, so for our
	f(1) value above, its size is roughly 0.7566, so no conclusion about
	it can yet be made.

	If the size test hasn't told us anything, then we continue by com-
	puting the next complex term in the sequence, and so on, until the
Š	size test disqualifies the original complex number OR we succeed in
	reaching the 1000th term, in which case we assume that the sequence
	will never "go to" infinity -- and so only then is the corresponding
	original point assumed to be in the Mandelbrot set.

	To further illustrate the process, we will compute a few more terms.

		f(2) = (-0.75 + 0.1i)(-0.75 + 0.1i) + (-0.75 + 0.1i)
		     = (0.5625 - 0.075i - 0.075i + 0.01i^2) + (-0.75 + 0.1i)
		     = (0.5525 - 0.15i) + (-0.75 + 0.1i)
		     = (-0.1975 - 0.05i)

		f(3) = (-0.1975 - 0.05i)(-0.1975 - 0.05i) + (-0.75 + 0.1i)
		     ....

	Notice how f(3) requires the result of f(2) for its calculation.
	Also notice that, in the second line of the f(2) computation, we must
	make use of the fact that i^2 (or i*i) is mathematically defined as
	-1, so that we can make the simplification in the third line.  Also,
	the "size" of f(2) computes to be roughly 0.2837, so the original
	number (-0.75 + 0.1i) seems to hold some hope of being a point in the
	Mandelbrot set.


	II. Using the Mandelbrot Microscope program

	This program allows you to specify a region of the complex number
	plane, and then proceeds to evaluate every point in the region that
	corresponds to a pixel (or point of light) on your screen.  The
	number of times the algorithm is performed for a pixel determines
	what will be graphed at that pixel:  if the maximum count was reached,
	then the point is displayed in black (the color reserved for points
	in the Mandelbrot set);  otherwise, a table is used to look up a
	color for the corresponding count, which allows you to visually group
	related regions of points.  Both these regions and the regions
	occupied by the Mandelbrot set combine to produce very irregular
	designs and shapes that truly defy the simplicity of the algorithm.

	To run the program, you only need MBROT.COM, but we also provide
	several pre-computed graphs which are stored in files like MBROT.1,
	MBROT.2, and so on.  Here's how it runs....

		A> MBROT

		Mandelbrot Microscope  Version 2.10
		Copyright by Radix 2 Software  May 1986

		Suggested values in ( ), default values in [ ]

		Restore from file (Y/[N])?

	At this point, press Y if you want to display a graph already
	computed, or N (or just the ENTER key, since N is the default re-
	sponse in square brackets) to create your own, new graph.  You can
	type Ctrl-C (or Ctrl-Break) at any time, to abort the program.  If
Š	you do so WHILE computing a graph on-screen, all computations up
	to the current point will be saved, so that you can later restore
	from that file (computation would then continue once the partial
	graph was redisplayed).

		Enter file #:

	If you are restoring a graph, enter its file number (such as 10 for
	MBROT.10).  If you are creating a new graph, enter a number for a
	file that does NOT exist, unless you KNOW the file with that name
	does not contain anything valuable to you.  Even in that case, you
	should delete the existing file first, then run MBROT, so that any
	previous information in the file won't be assumed to be part of the
	graph (this is just a tip in case the program is prematurely halted
	and you want to restore a partial graph).

	If you're creating a new graph, then the next six or seven questions
	will be asked.  When restoring a graph, the values entered at the
	time it was computed will be used.  (Although they can be changed,
	you need to understand the file format described below under section
	(V) -- Technical information, and be able to use DEBUG.COM or a
	similar program to change the file contents).

		X of center (-0.75):
		Y of center (+0.00):
		Width of window (2.5):
		Percentage of screen [100%]:
		Vertical/horizontal ratio [1.0]:
		Color (Y/[N])?
		High Resolution (640x200) (Y/[N])?

		Press any key to continue...

	X of center and Y of center are actually the "real" and "imaginary"
	parts, respectively, of the complex number in the CENTER of the
	region you want to graph.  For instance, on page 17 of the August
	1985 Scientific American, a picture of the Mandelbrot set is shown,
	and the region runs from -2.0 to 0.5 along the x-axis, and 1.25 to
	-1.25 down the y-axis.  To use this program to create a graph of
	that same region, compute the centers:  x is (-2.0 + 0.5)/2, or
	-0.75, and y is (1.25 + (-1.25))/2, or 0.  These, in fact, are the
	suggested values for those prompts, shown in parentheses.  They are
	not defaults, though -- to use them, you must type them in.

	The width of the window is how you control the "magnification".  To
	create basically the same image as the one mentioned above, compute
	(0.5 - (-2.0)), which is 2.5.  By entering 1.25 though (half of the
	first width), you would force the same screen area to examine
	a smaller region, and consequently more detail would be visible.

	The "Percentage of screen" is used to determine how large a percent-
	age of the screen width (and also height) to use in creating an image.
	For instance, 50% would create a centered image that was 1/2 the
	total possible width and height.  Since such an image would really be
	1/4 of the screen AREA (1/2 * 1/2), the computation time would be
Š	a mere 25% of the time required to complete a full-screen graph.  You
	can think of such an image as a lower-quality (poorer resolution)
	version of the same graph at 100%, or as a normal-quality graph that
	simply provides a restricted view of much larger region.

	The "Vertical/horizontal ratio" is used to compensate for the fact
	that most screens will show a flattened image, owing to the nature
	of the PC's graphics (200 by 320 pixels, for example), and also since
	a screen is usually wider than it is high.  If you don't mind the
	slightly distorted images, then nothing need be entered;  otherwise,
	try experimenting with values from .6 to .9 (we suggest .8).

	The last two questions just determine what graphics mode you want to
	use.  Only two basic modes are supported:  color (implying the low-
	resolution 320x200 mode), or the high-resolution monochrome mode.
	After this has been determined, press any key to commence graphing.


	III. Information on the sample graphs

	MBROT.1 is centered at (-0.75, 0.00), width 2.50, 50% size, .9 ratio.
	This shows pretty much the complete Mandelbrot set, as also shown on
	page 17 of the August 1985 issue of Scientific American.  The other
	single-graph files are also 50% size and .9 ratio, and the centers and
	widths are as follows.

	File #	Center		Width
	 2	 (-1.00, 0.20)	 2.00
	 3	 (-1.00, 0.20)	 1.75
	 4	 (-1.00, 0.20)	 1.40
	 5	 (-1.25, 0.25)	 1.12  and so on

	MBROT.MEM contains all the above MBROT graphs (in numerical sequence)
	to show how the program can give the sense of "zooming" into a region.
	If disk space is a premium, we suggest you delete this type of file
	before deleting the individual graph files, because the former contain
	all the information you need to experiment with color ranges, and any
	MEM file can be recreated from them later, if needed.



	IV. Advanced features

	When you create (or redisplay) a graph with MBROT, it will ring the
	system bell to indicate completion, and then simply wait for a
	key to be pressed before clearing the screen and returning to DOS.
	If you press "S" at that time, however, the image on the screen
	is appended to a special file, named MBROT.MEM.  Later, if you
	respond MEM to the "file number" prompt, all images saved in the MEM
	file are displayed in rapid succession.  This allows you to create a
	sequence of "frames" in a kind of Mandelbrot-movie (albeit, a rather
	slow movie, especially if the "frames" are 100% screen size).

	Although MBROT will append images only to the MEM file, you can later
	copy or rename that file to one with a different extension.  Upon re-
Š	storing, MBROT examines the contents of the file rather than the
	file's name to determine if it is a MEM file or a single graph, so
	there won't be any problem later on.

	Furthermore, when starting-up MBROT, there are several switches
	you can use to select additional features, and must be typed
	on the same line on which you invoke MBROT if they are to be used.

	/S	Causes the center x, center y, and width values to be dis-
		played, if there is room on the screen above and below the
		graph (in other words, the values will not be shown on a 100%
		screen-size graph).

	/L	Selects BACKGROUND operation.  Since background operation is
		only useful for computing graphs while the computer is used
		for other purposes, a NO response is assumed for the "Restore"
		prompt.  The file number prompt is for a file to write com-
		putations to, and all the other prompts are the same as des-
		cribed above.  After they're all answered, the program
		terminates, but remains resident and active until calculations
		are completed, at which time three successive bells will
		sound.  Also, the program will then repeatedly try to unload
		itself from memory -- and if you have loaded other resident
		software after MBROT (such as PCPal* or ASSIGN), those
		attempts will never succeed.  As a rule, to avoid problems,
		load all other resident software FIRST, then run MBROT /L.
                   (*PCPal is a Radix 2 Software product available soon
                     through shareware distribution.)

		Assuming you remain in text-mode, an indicator will begin
		flashing in the upper-right portion of your screen, implying
		that graph computations are indeed being performed.  That can
		be suppressed with the /S switch, however.  Since calculations
		may unduly slow other software, you can temporarily disable
		them by locking the Scroll-lock key.  They will also remain
		disabled as long as a Shift or Alt key is being held.

		There is currently no way of unloading the program manually,
		short of rebooting, and if in fact the program is abnormally
		ended, the graph file should have most of the information
		that was already computed.  However, the current version of
		the program will not allow you to continue a previous graph
		as a background operation.

	/C	Causes the Ctrl key to disable background calculations while
		being pressed, in the same manner that both Shift and
		Alt keys do (see /L for more info on background operation).

	/P	Selects pause operation when restoring from a MEM file.
		When viewing a sequence of images in a MEM file, you can use
		/P to force the program to pause after each frame, rather
		than immediately moving on to the next.  When there are no
		more frames, the program will ring the system bell once.
		And, if you use /B with /P, the program will ring the bell
		after every frame as well.
Š

	V. Technical information

	First, the program makes one deviation from the standard algorithm,
	as outlined in the brief description of the Mandelbrot set.  Our
	algorithm only performs up to 250 (instead of 1000) iterations, be-
	fore assuming that a point does indeed belong to the Mandelbrot set.
	This change will not radically affect the "correctness" of a graph,
	until you start focusing on very small regions where all the counts
	are very close to 250.  In such a case, to see more detail, a
	higher count limit is needed.  The same problem exists even with the
	1000 limit -- the higher number just postpones the problem until a
	greater degree of magnification is reached.  It's the author's
	opinion that the algorithm should have specified an amount by which
	the iteration limit increases as the size of region viewed decreases,
	even though the additional computation time would have become in-
	creasingly excessive.

	To address this situation, another switch (/M) is provided to mul-
	tiply the maximum count by a given integer.  For example, to compute
	a graph with a count limit of 1000 instead of 250, run MBROT /M4.
	Since the color table is only 250 entries, counts higher than 250
	are divided by 250, and the remainder becomes the effective count
	value.

	Memory requirements are normally only 8kb (virtually insignificant
	in a world where boards with several megabytes of RAM are becoming
	commonplace).  24kb is required when restoring images from a MEM
	file, since a 16kb buffer is used to assemble images before zapping
	them into the video segment.  Disk requirements when creating a graph
	are that 1) room exist in the directory for at least one additional
	file, and that 2) a minimum of 63kb of disk space (64384 bytes free)
	be available (or less for smaller graphs).  There is no option for
	computing a graph without saving the information;  this is mainly for
	your own protection, because -- even if for some reason you only want
	to see a graph once -- a power-failure or system crash could cost
	you a great deal of time in lost computations.

	The single-graph file format is described below (by byte offsets
	relative to 0)
	       0: bits 0-6 hold the video mode to be used,
		  and is normally only 4 (color/low-res), 5 (mono/
		  low-res), or 6 (mono/high-res).  bit 7 must be zero.
	       1: color palette to use (should only be zero or one);
		  when palette is zero, the color codes are:
			1-green		2-red		3-yellow
		  and when the palette is one, the color codes are:
			1-cyan		2-magenta	3-white
	       2: background color for low-res modes (intense color will
		  select an intense palette), or monochrome color for high-res
	       3: iteration limit multiplier (0 implies none)
	    4-11: x of center of graph
	   12-19: y of center of graph
	   20-27: width of graph
Š	   28-35: percentage of screen
	   36-43: vertical/horizontal ratio
	  44-127: reserved (for additional information)
	 128-383: color codes (normally 1-3) for all possible counts, up
		  to 255;  that is, offset 128 holds the color for points
		  that lasted 1 iteration, offset 129 for points of 2 itera-
		  tions, and so on, up to offset 376 for 249 iterations;
		  Mandelbrot points (those that have the max. count of 250)
		  always use the last byte (at offset 383) for their color,
		  so bytes at offsets 377 to 382 are not normally used (when
		  the maximum count is higher than 250, the byte at 377 is
		  used to round out the table to 250 entries).
	 384----: each byte has an algorithm iteration count for a specific
		  pixel, and they are stored sequentially, as computed (all
		  columns from left to right for the top row, then the next
		  row, and so on);  currently, the minimum value is 1 and the
		  next-to-maximum value is 249 (F9h) (FAh-FFh reserved for
		  Mandelbrot and other special points), and 0 indicates the
		  end of a partial graph.

	To use DEBUG.COM to alter any of those fields, load the file with
	Debug (as in A>DEBUG MBROT.1), add 256 to the proper offset listed
	above and convert to hex (i.e., 384+256=640 or 280hex);  then, using
	our example, type E 280 to view the first byte of the color table.
	At that point, you can enter a new value (in hex), press space to
	skip to the next, or press Enter to return to Debug's dash-prompt.
	Afterward, to save any changes, type W at the prompt and press Enter.
	To exit Debug and return to the DOS prompt, use Debug's Q command.

	The multiple-graph MEM file format is similar to the above format
	for the first 128 bytes (offsets 0-127), with the sole exception that
	bit 7 of the first byte (offset 0) must be one.  The rest of file
	contains variable-length records, each of which have the same rela-
	tive format:

	     0-1: offset into the video segment, at which position
		  the data at the end of this record will be copied;
		  the segment is always assumed to be B800(hex).
	       2: the number of bytes of data following.
	     3--: the data to be copied directly into the video segment.

	When a video offset (bytes 0-1) of FFFF(hex) is found, the corres-
	ponding image is assumed to be ended, and nothing else should exist
	on such a record.  The file will continue to be read until all images
	in the file are exhausted, so unless an overlarge file is not padded
	with FFFF(hex), garbage will likely appear on the screen.  This is
	only likely to happen with a file that's become damaged, or incorrect-
	ly created or modified by another program.

	MBROT.COM is written entirely in assembly language, since we wanted
	to create the fastest version possible.  Since all calculations that
	require floating-point use an 8-byte format that provides roughly 16
	significant digits of precision, there may be faster versions of this
	program available, but they're not likely to offer the same precision,
	nor consequently the same degree of resolution when magnifying images.
Š	There is no built-in support for any floating-point co-processors, so
	having one will not affect the computations in any way.

	Source code may be made available to interested parties.  Microsoft
	Macro Assembler V4.0 was used, and minor modifications might be
	required for use with another assembler, or an earlier version of the
	same.  Our business address is:

		Radix 2 Software
		P.O. Box 1230
		Loomis, California  95650			      5/86 JP
